home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
util
/
conv
/
MIDI2asm.lha
/
MIDI2asm.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1998-02-09
|
3KB
|
121 lines
/* $VER: MIDI2asm 0.9 $ */
/* Convert MIDI data to assembler source */
/* © by Stefan Haubenthal 1998 */
if ~open(midi,arg(1)) then exit 0*writeln(stdout,"Usage: MIDI2asm midifile")
say ";" arg(1) "V"word(sourceline(1),4)
say
say "DELTA macro"
say " ifgt \1-16383"
say " dc.b \1>>14|128"
say " endc"
say " ifgt \1-127"
say " dc.b \1>>7&$ff|128"
say " endc"
say " dc.b \1&127"
say " endm"
say "noteoff=$80"
say "noteon=$90"
say "polypress=$A0"
say "ctrl=$B0"
say "prog=$C0"
say "chanpress=$D0"
say "pitchbend=$E0"
say "sysex=$F0"
say "meta=$FF"
/*
say "seqnum=$00" /* sequence_number */
say "text=$01" /* text_event */
say "copyright=$02" /* copyright_notice */
say "sname=$03" /* sequence_name */
say "iname=$04" /* instrument_name */
say "lyric=$05" /* lyric */
say "marker=$06" /* marker */
say "cue=$07" /* cue_point */
say "cprefix=$20" /* channel_prefix */
say "trackend=$2f" /* end_of_track */
say "tempo=$51" /* set_tempo */
say "smpte=$54" /* smpte_offset */
say "time=$58" /* time_signature */
say "key=$59" /* key_signature */
say "seqspec=$74" /* sequencer_specific */
*/
say
say " data"
say ' dc.b "'readch(midi,4)'"'
say " dc.l "c2d(readch(midi,4))
say " dc.w "c2d(readch(midi,2)) "format"
tracks=c2d(readch(midi,2))
say " dc.w "tracks "tracks"
tempo=c2d(readch(midi,2))*4
say " dc.w "tempo/4 "tempo"
do track=1 to tracks
say
say "; track" track
say ' dc.b "'readch(midi,4)'"'
len=c2d(readch(midi,4))
/*say " dc.l "len "size"*/
parse value d2x(len,8) with len1 3 len2 5 len3 7 len4
say " dc.b $"len1",$"len2",$"len3",$"len4 "size"
time=0
measure=0
do forever
data=c2d(readch(midi))
if data<128 then delta=data
else do
delta=(data-128)*128
data=c2d(readch(midi))
if data<128 then delta=delta+data
else delta=delta*128+(data-128)*128+c2d(readch(midi))
end
time=time+delta
if time/tempo=measure then do
say "; measure" time/tempo+1
measure=measure+1
end
say " DELTA "delta
data=c2x(readch(midi))
select
when data<"80" then /* short event */
say " dc.b "x2d(data)","c2d(readch(midi))
when left(data,1)="8" then
say " dc.b noteoff+"x2d(right(data,1))","c2d(readch(midi))","c2d(readch(midi))
when left(data,1)="9" then
say " dc.b noteon+"x2d(right(data,1))","c2d(readch(midi))","c2d(readch(midi))
when left(data,1)="A" then
say " dc.b polypress+"x2d(right(data,1))","c2d(readch(midi))","c2d(readch(midi))
when left(data,1)="B" then
say " dc.b ctrl+"x2d(right(data,1))","c2d(readch(midi))","c2d(readch(midi))
when left(data,1)="C" then
say " dc.b prog+"x2d(right(data,1))","c2d(readch(midi))
when left(data,1)="D" then
say " dc.b chanpress+"x2d(right(data,1))","c2d(readch(midi))
when left(data,1)="E" then
say " dc.b pitchbend+"x2d(right(data,1))","c2d(readch(midi))","c2d(readch(midi))
when data="F0" then do
len=c2d(readch(midi))
say " dc.b sysex,"len
call dump
end
when data="FF" then do
data=c2x(readch(midi))
len=c2d(readch(midi))
say " dc.b meta,$"data","len
select
when left(data,1)="0" then
if len>1 then say ' dc.b "'readch(midi,len)'"'
else call dump
when data="2F" then leave
otherwise call dump
end
end
end
end
end
exit
dump:
do i=1 to len
say " dc.b $"c2x(readch(midi))
end